﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;

namespace AdapterTool_Demo
{
    public partial class ChangePasswordForm : Form
    {
        private string m_oldpwd;
        private string m_newpwd1;
        private string m_newpwd2;

        // get and set OldPassword
        public string OldPassword
        {
            get { return m_oldpwd; }
            set { m_oldpwd = value; }
        }

        // get and set NewPassword1
        public string NewPassword1
        {
            get { return m_newpwd1; }
            set { m_newpwd1 = value; }
        }

        // get and set NewPassword2
        public string NewPassword2
        {
            get { return m_newpwd2; }
            set { m_newpwd2 = value; }
        }

        public ChangePasswordForm()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            m_oldpwd = textBox1.Text;
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            m_newpwd1 = textBox2.Text;
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            m_newpwd2 = textBox3.Text;
        }

        // OK
        private void button1_Click(object sender, EventArgs e)
        {
            // 1. check m_newpwd1 == m_newpwd2
            if (m_newpwd1 == m_newpwd2)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            { 
                // give warning to re-input
                MessageBox.Show("Two new passwords are different, please input again!", "Warning");
                return;
            }
        }

        // cancel
        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
